#!/bin/bash
WORK_PATH='/usr/local/ymxl.me/daily-hot-master'
cd $WORK_PATH
echo "清理代码"
git reset --hard origin/master
git clean -f
echo "拉取最新代码"
git pull origin master
echo "打包最新代码"
npm run build
echo "开始构建镜像"
docker build -t daily-hot-master:1.0 .
echo "删除旧容器"
docker stop daily-hot-master-container
docker rm daily-hot-master-container
echo "启动新容器"
#docker container run -p 8899:8899 -d --name daily-hot-master-container daily-hot-master:1.0
docker container run -p 80:80 -p 443:443 -d --name daily-hot-master-container daily-hot-master:1.0
echo "删除名称为none的镜像"
docker images | grep none | awk '{print $3}' | xargs docker rmi